package com.hm.cms.websit;

import com.hm.cms.vo.HcmsArticleVo;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class DidispaceBlog {

    private static int timeout = 3000000;

    public static void main(String[] args) throws Exception{
        String uri = "http://blog.didispace.com/spring-boot-starter-swagger-1.3.0/";
        Document document = Jsoup.connect(uri).data("query", "Java").userAgent("Mozilla").cookie("auth", "token").timeout(timeout).get();

        String keyStr = "Spring Boot, Spring Cloud, 微服务";
        Element element = document.getElementsByClass("article-entry").get(0);
        element.removeClass("copyright-left");
        element.removeClass("center");

        HcmsArticleVo articleVo = new HcmsArticleVo();


        System.out.println(document.getElementsByClass("article-title").get(0).html());
        articleVo.setTitle(document.getElementsByClass("article-title").get(0).html());
        System.out.println(element.html());


        System.out.println(articleVo.toString());
    }

    public static void loadCategries() throws Exception{
        String uri = "http://blog.didispace.com/categories/Spring-Boot/";
        Document document = Jsoup.connect(uri).data("query", "Java").userAgent("Mozilla").cookie("auth", "token").timeout(timeout).get();

        Elements elements = document.getElementsByClass("timeline-article-title");
        for(Element el:elements){
            System.out.println("http://blog.didispace.com"+el.attr("href"));
        }
    }
}
